package com.wxy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wxy.domain.StudentExam;
import com.wxy.mapper.StudentExamMapper;
import com.wxy.service.StudentExamService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Service
public class StudentExamServiceImpl extends ServiceImpl<StudentExamMapper, StudentExam>implements StudentExamService {
    @Override
    public List<Map<String,Object>> countStu(Long examId) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.select("count(*) as 'sum'")
                .eq("exam_id",examId);
        //int count =  this.getOne(queryWrapper);
        Map<String,Object> map1= this.getMap(queryWrapper);
        QueryWrapper<StudentExam> queryWrapper1 = new QueryWrapper();
        queryWrapper1.select("count(*) as sum1")
                        .lambda()
                        .eq(StudentExam::getStatus,1)
                        .eq(StudentExam::getExamId,examId);
        Map<String,Object> map2= this.getMap(queryWrapper1);
        List<Map<String,Object>> list = new ArrayList();
        list.add(map1);
        list.add(map2);
        return list;
    }
}
